Next: MIPS Stabs, Previous: MIPS Opts, Up: MIPS-Dependent

#### 9.22.2 MIPS ECOFF object code

Assembling for a mips ecoff target supports some additional sections besides the usual `.text`, `.data` and `.bss`. The additional sections are `.rdata`, used for read-only data, `.sdata`, used for small data, and `.sbss`, used for small common objects.

When assembling for ecoff, the assembler uses the `$gp` (`$28`) register to form the address of a “small object”. Any object in the `.sdata` or `.sbss` sections is considered “small” in this sense. For external objects, or for objects in the `.bss` section, you can use the `gcc` -G option to control the size of objects addressed via `$gp`; the default value is 8, meaning that a reference to any object eight bytes or smaller uses `$gp`. Passing -G 0 to `as` prevents it from using the `$gp` register on the basis of object size (but the assembler uses `$gp` for objects in `.sdata` or `sbss` in any case). The size of an object in the `.bss` section is set by the `.comm` or `.lcomm` directive that defines it. The size of an external object may be set with the `.extern` directive. For example, .extern sym,4 declares that the object at `sym` is 4 bytes in length, whie leaving `sym` otherwise undefined.

Using small ecoff objects requires linker support, and assumes that the `$gp` register is correctly initialized (normally done automatically by the startup code). mips ecoff assembly code must not modify the `$gp` register.